package com.easybuyzjf.web;

import com.easybuyzjf.model.EbProduct;
import com.easybuyzjf.service.EbProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/product")
public class EbProductController {
    @Autowired
    private EbProductService ebProductService;
    @RequestMapping("/detail")
    public String detail(Model model,int epId){
        EbProduct ebProduct= ebProductService.detail(epId);

        model.addAttribute("product",ebProduct);
        return "product-view";
    }

    @RequestMapping("/add_car")
    public String addCar(int epId, HttpServletRequest request){
        // TODO 1.调用service将商品加入购物车
        ebProductService.addCar(epId,request);
        // TODO 2.绑定数据到model--数据
        //不需要 因为在service已经将数据放到session中了
        //TODO 3.返回view --html
        return "shopping";
    }
}
